import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.*;
import model.BasicParameter;
import model.ParameterValue;
import model.solver.MiniSatParameter;

import org.junit.Test;

public class TestMiniSatParameter {
	@Test
	public void testRefuseParameter() {
		MiniSatParameter param = new MiniSatParameter();

		assertFalse("set grow with incorrect value", param.setGrow(-10));

		assertFalse("set decay with wrong value", param.setDecay(MiniSatParameter.MIN_DECAY - 1));
		assertFalse("set decay with wrong value", param.setDecay(MiniSatParameter.MAX_DECAY + 1));

		assertFalse("set rnd freq with wrong value", param.setRndfreq(MiniSatParameter.MIN_RND_FREQ - 1));
		assertFalse("set rnd freq with wrong value", param.setRndfreq(MiniSatParameter.MAX_RND_FREQ + 1));
	}

	@Test
	public void testBasicParameter() {
		MiniSatParameter basic = new MiniSatParameter();

		basic.setTimeOut(BasicParameter.NO_DELAY);
		assertFalse("set NO_DELAY return need timeout", basic.needTimeOut());

		basic.setTimeOut(BasicParameter.MIN_DELAY);
		assertTrue("min delay consider as no delay", basic.needTimeOut());

		assertEquals("return wrong value for timeout : " + basic.getTimeOut() + " instead of : "
				+ BasicParameter.MIN_DELAY, BasicParameter.MIN_DELAY, basic.getTimeOut());

		basic.setTimeOut(BasicParameter.MIN_DELAY - 1);
		assertFalse("check doesn't detect to low timeout", basic.basicCheck());

		assertEquals("return wrong value for timeout : " + basic.getTimeOut() + " instead of : "
				+ BasicParameter.MIN_DELAY, BasicParameter.MIN_DELAY - 1, basic.getTimeOut());

	}

	@Test
	public void testCheckParameter() {
		MiniSatParameter param = new MiniSatParameter();

		param.setTimeOut(BasicParameter.MIN_DELAY);

		param.setDecay(1);
		param.setGrow(2);
		param.setPolarityMode(ParameterValue.NOT_USED);
		param.setPre(false);
		param.setRcheck(ParameterValue.FALSE);
		param.setRndfreq(MiniSatParameter.NOT_USED);
		param.setVerbosity(0);

		assertTrue("check give error when it shouldn't", param.basicCheck());
	}
}
